//
//  MatchingSuccessView.m
//  YiXiProject
//
//  Created by xingshuai on 2019/8/4.
//  Copyright © 2019 iMac. All rights reserved.
//

#import "MatchingSuccessView.h"

@implementation MatchingSuccessView

-(UIImageView *)meImg
{
    if(!_meImg)
    {
        _meImg = [[UIImageView alloc] init];
        _meImg.backgroundColor = WhiteColor;
        _meImg.layer.cornerRadius = 50;
        _meImg.layer.masksToBounds = YES;
    }
    return _meImg;
}

-(UIImageView *)youImg
{
    if(!_youImg)
    {
        _youImg = [[UIImageView alloc] init];
        _youImg.backgroundColor = WhiteColor;
        _youImg.layer.cornerRadius = 50;
        _youImg.layer.masksToBounds = YES;
    }
    return _youImg;
}

-(UIButton *)speakBtn
{
    if(!_speakBtn)
    {
        _speakBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        _speakBtn.frame = CGRectMake(-SCREEN_WIDTH, SCREEN_HEIGHT/2+80, SCREEN_WIDTH-100, 50);
        [_speakBtn setTitle:@"Speak" forState:UIControlStateNormal];
        _speakBtn.titleLabel.font = HeiTiFont(28);
        [_speakBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _speakBtn.layer.cornerRadius = 25;
        _speakBtn.layer.masksToBounds = YES;
        _speakBtn.layer.borderWidth = 2;
        _speakBtn.layer.borderColor = WhiteColor.CGColor;
        _speakBtn.tag = 100;
        [_speakBtn addTarget:self action:@selector(matchBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _speakBtn;
}

-(UIButton *)sweepBtn
{
    if(!_sweepBtn)
    {
        _sweepBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        _sweepBtn.frame = CGRectMake(SCREEN_WIDTH, SCREEN_HEIGHT/2+160, SCREEN_WIDTH-100, 50);
        [_sweepBtn setTitle:@"keep Sweep" forState:UIControlStateNormal];
        _sweepBtn.titleLabel.font = HeiTiFont(28);
        [_sweepBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _sweepBtn.layer.cornerRadius = 25;
        _sweepBtn.layer.masksToBounds = YES;
        _sweepBtn.layer.borderWidth = 2;
        _sweepBtn.layer.borderColor = WhiteColor.CGColor;
        _sweepBtn.tag = 101;
        [_sweepBtn addTarget:self action:@selector(matchBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _sweepBtn;
}


-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self addSubview:self.meImg];
        [self addSubview:self.youImg];
        [self addSubview:self.speakBtn];
        [self addSubview:self.sweepBtn];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    _meImg.sd_layout.rightSpaceToView(self, SCREEN_WIDTH/2+15).topSpaceToView(self, SCREEN_HEIGHT/2-50).widthIs(100).heightIs(100);
    
    _youImg.sd_layout.leftSpaceToView(self, SCREEN_WIDTH/2+15).topSpaceToView(self, SCREEN_HEIGHT/2-50).widthIs(100).heightIs(100);
}

-(void)matchBtnClick:(UIButton *)butt
{
    if([_delegate respondsToSelector:@selector(matchClickBtnTag:)])
    {
        [_delegate matchClickBtnTag:butt.tag];
    }
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
